package codeflyer.server;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import codeFlyer.web.api.Filter;
import codeFlyer.web.api.HttpApplicationContext;
import codeFlyer.web.api.HttpContextListener;
import codeFlyer.web.api.HttpServlet;
import codeFlyer.web.api.Listener;

/**
 * @author CodeFlyer
 * @date May 10, 2020
 * @version 1.0
 */

public class ApplicationContext implements HttpApplicationContext{

	private Map<String, Object> application = new HashMap<String, Object>();

	public Map<String, Object> getApplication() {
		return application;
	}

	public void setApplication(Map<String, Object> application) {
		this.application = application;
	}
	
	public void setAttribute(String string,Object object) {
		application.put(string, object);
	}
	
	public Object getAttribute(String string) {
		return application.get(string);
	}

	public ApplicationContext(List<Listener> listeners) {
		//在创建对象时调用监听器
		for (Listener listener : listeners) {
			if(listener instanceof HttpContextListener) {
				((HttpContextListener) listener).ApplicationCreated();
			}
		}
	}
}


